home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Tool Chest / Development Kits / MPW etc. / Debuggers / SADE / SADE 1.3.3 / SadeUserStartup•Extras < prev    next >
Encoding:
Text File  |  1992-06-12  |  4.5 KB  |  122 lines  |  [TEXT/sade]

  1. #Name of the window for 'value in context'
  2. Define __gValueInContextWindowName__
  3.  
  4. # Given a variable name, this routine displays it in a new window if the name of window
  5. # will be 32 chars or less
  6. PROC __PutValueInWindow__(__TheVarName__)
  7.     __gValueInContextWindowName__ := Concat(__ScratchDir__, __TheVarName__)
  8.  
  9.     Define __EvaledVar__ := CheckedEval(__TheVarName__,'Undefined or out of scope: ')
  10.  
  11.     Define __TopOfFile__
  12.     IF Length(__TheVarName__) < 33 THEN
  13.         Redirect __gValueInContextWindowName__
  14.         CheckValidLocalVars
  15.         PrettyPrintValue(__TheVarName__)
  16.         Redirect Pop
  17.         __TopOfFile__ := Selection(__gValueInContextWindowName__,0,0) # Puts cursor at top of window
  18.     ELSE
  19.         __gValueInContextWindowName__ := __gValueWindow__
  20.         Redirect Append __gValueInContextWindowName__
  21.         CheckValidLocalVars
  22.         PrettyPrintValue(__TheVarName__)
  23.         Redirect Pop
  24.     END
  25. END
  26.  
  27. # Given a selection (hopefully a field name) in a ShowValue2 window,
  28. # this routine returns the string 'ParentName.field'
  29. FUNC __FindVarName__(__TheVarName__)
  30.     IF ActiveWindow = __gValueWindow__ THEN
  31.         # If the selection is in the Value window,
  32.         # we can not guess which variable the user is talking about
  33.         Return __TheVarName__
  34.     END
  35.  
  36.     IF __GetDirectoryFromFullPath__(ActiveWindow) <> __ScratchDir__ THEN
  37.         # The selection is probably in the source code,
  38.         # we can not guess which variable the user is talking about
  39.         Return __TheVarName__
  40.     END
  41.     
  42.     # We will find the leaf name of the window
  43.     Define ParentName := __GetFileFromFullPath__(ActiveWindow)
  44.     # Append the field name to that of its parent struct
  45.     __TheVarName__ := Concat(ParentName, Concat('.', __TheVarName__))
  46.     Return __TheVarName__
  47. END
  48.  
  49. # Like Show Value, but try to qualify the selection with a parent name.
  50. # Also, open a new window if possible
  51. PROC __HandleShowValue2__(__Selection__)
  52.     CheckNullOrRunningTarget
  53.     __CheckNullSelection__(__Selection__)
  54.     Define __TheVarName__ := __FindVarName__(__Selection__)
  55.     __PutValueInWindow__(__TheVarName__)
  56.     Open __gValueInContextWindowName__
  57. END
  58.  
  59. PROC __HandleShowDereferencedValue2__(__Selection__)
  60.     CheckNullOrRunningTarget
  61.     __CheckNullSelection__(__Selection__)
  62.     Define __TheVarName__ := __FindVarName__(__Selection__)
  63.     __CheckPointer__(__TheVarName__)
  64.     __PutValueInWindow__(Concat(__TheVarName__,'^'))
  65.     Open __gValueInContextWindowName__
  66. END
  67.  
  68. PROC __SetValue__
  69.     CheckNullOrRunningTarget
  70.     Define __Selection__ := Selection(ActiveWindow)
  71.     __CheckNullSelection__(__Selection__)
  72.     Define __TheVarName__ := __FindVarName__(__Selection__)
  73.     # IF we can not display the value of the variable, we are not going to be able to set it
  74.     Define __EvaledVar__ := CheckedEval(__TheVarName__,'Could not evaluate left hand side :')
  75.     Define __Condition__ := Request(Concat(__TheVarName__, ' = ?'))
  76.     IF __Condition__ = '_CANCEL_' THEN
  77.         ABORT
  78.     END
  79.     Define __EvaledCondition__
  80.     Define __AssignmentExpr__
  81.     Define __EvaledAssignmentExpr__
  82.     IF __Condition__ = '' THEN
  83.         __Fail__('No value was specified, not modified.')
  84.     ELSE
  85.         # check for valid right hand side
  86.         __EvaledCondition__ := CheckedEval(__Condition__, 'Could not evaluate right hand side of assignment: ')
  87.  
  88.         # check for valid condition
  89.         __AssignmentExpr__ := Concat(Concat(__TheVarName__, ' := '), __Condition__)
  90.         __EvaledAssignmentExpr__ := CheckedEval(__AssignmentExpr__, 'Assignment failed.')
  91.     END
  92. END
  93.  
  94. PROC __ShowHandleObject__(__Object__)
  95.     CheckNullOrRunningTarget
  96.     __CheckPointer__(__Object__)
  97.     Define __OnceDeref__ := CheckedEval(Concat(__Object__,'^'),'Undefined/Out of scope: ')
  98.     __CheckPointer__(__OnceDeref__)
  99.     __PutValueInWindow__(Concat(__Object__, '^^'))
  100.     Open __gValueInContextWindowName__
  101. END
  102.  
  103. PROC __DoubleDeref__
  104.     CheckNullOrRunningTarget
  105.     Define __Handle__ := Selection(ActiveWindow)
  106.     __CheckNullSelection__(__Handle__)
  107.     Define __TheVarName__ := __FindVarName__(__Handle__)
  108.     __CheckPointer__(__TheVarName__)
  109.     Define __OnceDeref__ := CheckedEval(Concat(__TheVarName__,'^'),'Undefined/Out of scope: ')
  110.     __PutValueInWindow__(Concat(__TheVarName__,'^^'))
  111.     Open __gValueInContextWindowName__
  112. END
  113.  
  114. Addmenu 'Extras'  'Show Value In Context/2'              '__HandleShowValue2__(Selection(ActiveWindow))'    # Cmd-2
  115. Addmenu 'Extras'  'Show Dereferenced Value In Context/3'    '__HandleShowDereferencedValue2__(Selection(ActiveWindow))'    # Cmd-3
  116. Addmenu 'Extras'  'Set Value /='                        '__SetValue__'
  117. Addmenu 'Extras'  '(-'                 ''
  118. Addmenu 'Extras'  'Show **this/4'                        '__ShowHandleObject__("this")'    #For MacApp/C++ programmers
  119. Addmenu 'Extras'  'Show *this'                            '__HandleShowDereferencedValue2__("this")'    #For non-MacApp/C++ programmers
  120. Addmenu 'Extras'  'Twice Dereference Selection/5'        '__DoubleDeref__'
  121.  
  122.